package com.ruoyi.volunteer.recruit.service.impl;

import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.volunteer.recruit.mapper.VoluntaryRecruitMapper;
import com.ruoyi.volunteer.recruit.domain.VoluntaryRecruit;
import com.ruoyi.volunteer.recruit.service.IVoluntaryRecruitService;

/**
 * 报名管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-13
 */
@Service
public class VoluntaryRecruitServiceImpl implements IVoluntaryRecruitService 
{
    @Autowired
    private VoluntaryRecruitMapper voluntaryRecruitMapper;

    /**
     * 查询报名管理
     * 
     * @param id 报名管理主键
     * @return 报名管理
     */
    @Override
    public VoluntaryRecruit selectVoluntaryRecruitById(Long id)
    {
        return voluntaryRecruitMapper.selectVoluntaryRecruitById(id);
    }

    @Override
    public VoluntaryRecruit selectVoluntaryRecruitByUserIdAndActivityId(Long userId, Long activityId) {
        return voluntaryRecruitMapper.selectVoluntaryRecruitByUserIdAndActivityId(userId, activityId);
    }

    @Override
    public Long selectVoluntaryRecruitNumber(Long activityId) {
        return voluntaryRecruitMapper.selectVoluntaryRecruitNumber(activityId);
    }

    /**
     * 查询报名管理列表
     * 
     * @param voluntaryRecruit 报名管理
     * @return 报名管理
     */
    @Override
    public List<VoluntaryRecruit> selectVoluntaryRecruitList(VoluntaryRecruit voluntaryRecruit)
    {
        List<VoluntaryRecruit> list = voluntaryRecruitMapper.selectVoluntaryRecruitList(voluntaryRecruit);
        if (voluntaryRecruit.getActivityName() != null) {
            List<VoluntaryRecruit> list1 = new ArrayList<>();
            for (VoluntaryRecruit v : list) {
                if (v.getActivityName().contains(voluntaryRecruit.getActivityName())) {
                    list1.add(v);
                }
            }
            return list1;
        }
        return list;
    }

    @Override
    public List<VoluntaryRecruit> selectVoluntaryRecruitUserList(Long activityId) {
        return voluntaryRecruitMapper.selectVoluntaryRecruitUserList(activityId);
    }

    /**
     * 新增报名管理
     * 
     * @param voluntaryRecruit 报名管理
     * @return 结果
     */
    @Override
    public int insertVoluntaryRecruit(VoluntaryRecruit voluntaryRecruit)
    {
        return voluntaryRecruitMapper.insertVoluntaryRecruit(voluntaryRecruit);
    }

    /**
     * 修改报名管理
     * 
     * @param voluntaryRecruit 报名管理
     * @return 结果
     */
    @Override
    public int updateVoluntaryRecruit(VoluntaryRecruit voluntaryRecruit)
    {
        return voluntaryRecruitMapper.updateVoluntaryRecruit(voluntaryRecruit);
    }

    /**
     * 批量删除报名管理
     * 
     * @param ids 需要删除的报名管理主键
     * @return 结果
     */
    @Override
    public int deleteVoluntaryRecruitByIds(Long[] ids)
    {
        return voluntaryRecruitMapper.deleteVoluntaryRecruitByIds(ids);
    }

    /**
     * 删除报名管理信息
     * 
     * @param id 报名管理主键
     * @return 结果
     */
    @Override
    public int deleteVoluntaryRecruitById(Long id)
    {
        return voluntaryRecruitMapper.deleteVoluntaryRecruitById(id);
    }
}
